package jianzhi

func levelOrder1(root *TreeNode) []int {

	res := []int{}

	if root == nil {
		return res
	}

	stack := []*TreeNode{root}

	for len(stack) > 0 {
		temp := stack[0]
		res = append(res, temp.Val)
		if temp.Left != nil {
			stack = append(stack, temp.Left)
		}
		if temp.Right != nil {
			stack = append(stack, temp.Right)
		}

		stack = stack[1:]

	}

	return res
}
